package br.com.cogerh.sidec.model;

import java.util.List;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import com.sun.istack.internal.Nullable;

@Entity
@Table(schema = "adm")
public class Pessoa {
	
	
	
	@Id
	@GeneratedValue
	@Column(name = "id_pessoa")
	private Integer id;
	private String matricula;
	private String nome;
	private String email;
	
	
	@ManyToOne(cascade = CascadeType.ALL)
	@Nullable
	private Gerencia gerencia;
	
	@ManyToMany(cascade = CascadeType.REMOVE )
	private Set<Reuniao> listaReunioes;

	public Pessoa(){
		
	}
		
	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public String getMatricula() {
		return matricula;
	}

	public void setMatricula(String matricula) {
		this.matricula = matricula;
	}

	public String getNome() {
		return nome;
	}

	public void setNome(String nome) {
		this.nome = nome;
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}



	public Gerencia getGerencia() {
		return gerencia;
	}



	public void setGerencia(Gerencia gerencia) {
		this.gerencia = gerencia;
	}

	
	
	


	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((email == null) ? 0 : email.hashCode());
		result = prime * result
				+ ((gerencia == null) ? 0 : gerencia.hashCode());
		result = prime * result + ((id == null) ? 0 : id.hashCode());
		result = prime * result
				+ ((matricula == null) ? 0 : matricula.hashCode());
		result = prime * result + ((nome == null) ? 0 : nome.hashCode());
		return result;
	}



	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Pessoa other = (Pessoa) obj;
		if (email == null) {
			if (other.email != null)
				return false;
		} else if (!email.equals(other.email))
			return false;
		if (gerencia == null) {
			if (other.gerencia != null)
				return false;
		} else if (!gerencia.equals(other.gerencia))
			return false;
		if (id == null) {
			if (other.id != null)
				return false;
		} else if (!id.equals(other.id))
			return false;
		if (matricula == null) {
			if (other.matricula != null)
				return false;
		} else if (!matricula.equals(other.matricula))
			return false;
		if (nome == null) {
			if (other.nome != null)
				return false;
		} else if (!nome.equals(other.nome))
			return false;
		return true;
	}



	public Set<Reuniao> getListaReunioes() {
		return listaReunioes;
	}



	public void setListaReunioes(Set<Reuniao> listaReunioes) {
		this.listaReunioes = listaReunioes;
	}




}
